package org.example.crazy.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.crazy.domain.User;

import java.util.List;

/**
 * @Author yzz
 * @CreateTime 2025/03/11
 * @Description DemoApplication
 */
public interface UserMapper extends BaseMapper<User> {

    @Select("<script>"+
            "SELECT * FROM USER WHERE id in " +
            "<foreach collection=\"ids\" item=\"id\" open=\"(\" separator=\",\" close=\")\">" +
            "#{id}" +
            "</foreach>" +
            "</script>")
    List<User> getUsersByDaoAnnotation(@Param("ids") List<Integer> ids);

    /**
     * @param list
     * @return List<User>
     */
//    List<User> getUsersByDaoXml(List<Integer> list);

    /**
     * 使用 foreach 时，参数变量名不是 list 要加 @Param()
     * @param ids
     * @return List<User>
     */
    List<User> getUsersByDaoXml(@Param("ids") List<Integer> ids);
}